﻿using System;
using System.Diagnostics;
using System.IO;
using System.Text.RegularExpressions;
using YArchitech.LIB;
using HYCodeBase.ObjectPersistentSuit;

namespace HYRevitCode.RevitObjectSerializeUtility
{
	public class HYRevitObjectSerializeManger : BasePersistentManger
	{
		public HYRevitObjectSerializeManger() : base(new AssemblyFileFilterDelegate(HYRevitObjectSerializeManger.IfFileFiltered))
		{
			base.BasePath = Product.UserDataLocation;
		}

		private static bool IfFileFiltered(FileInfo inputFileInfo)
		{
			if (inputFileInfo == null)
			{
				return true;
			}
			FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(inputFileInfo.FullName);
			return !Regex.IsMatch(inputFileInfo.Name, ".*\\.dll", RegexOptions.IgnoreCase) || (Regex.IsMatch(versionInfo.ProductName, "Autodesk", RegexOptions.IgnoreCase) && (!inputFileInfo.Name.Equals("RevitAPI.dll") || inputFileInfo.Name.Equals("RevitAPIUI.dll")));
		}

		private const string m_strRevitAPI = "RevitAPI.dll";

		private const string m_strRevitAPIUI = "RevitAPIUI.dll";

		private const string m_strAutodesk = "Autodesk";

		private const string m_strDll = ".*\\.dll";
	}
}
